1
'*************************** Module Header ******************************'
2 ' Module Name: FieldNamingRule.vb
3 ' Project: VBCustomCodeAnalysisRule
4 ' Copyright (c) Microsoft Corporation.
6 ' The class FieldNamingRule inherits the class Microsoft.FxCop.Sdk.BaseIntrospectionRule
7 ' and override the method
8 ' public ProblemCollection Check(Member member).
10 ' This rule is use to check whether a field name starts with a lowercase character.
12 ' This source is subject to the Microsoft Public License.
13 ' See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
14 ' All other rights reserved.
16 ' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
17 ' EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
18 ' WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
19 '**************************************************************************'
21 Imports Microsoft
.FxCop
.Sdk
23 Friend NotInheritable Class FieldNamingRule
24 Inherits BaseIntrospectionRule
26 ''' Define the rule name, resource file and resource assembly.
29 MyBase
.New("FieldNamingRule", "VBCustomCodeAnalysisRule.Rules",
30 GetType(FieldNamingRule
).Assembly
)
35 ''' Check the name of the member if it is a field.
36 ''' If the field is not an event or an static menber, its name should
37 ''' start with a lowercase character.
39 Public Overrides
Function Check(ByVal memb
As Member
) _
41 If TypeOf memb Is Field
Then
42 Dim fld
As Field
= TryCast(memb
, Field
)
44 If Not (TypeOf fld
.Type Is DelegateNode
) _
45 AndAlso (Not fld
.IsStatic
) Then
47 If fld
.Name
.Name(0) < "a"c _
48 OrElse fld
.Name
.Name(0) > "z"c
Then
50 Me.Problems
.Add(New Problem(
51 Me.GetNamedResolution("LowercaseField",
53 fld
.DeclaringType
.FullName
)))